#pragma GCC optimize(2, "Ofast", "inline")
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <algorithm>
#define endl '\n'
#define int long long
#define pii pair<int, int>
using namespace std;

// 已知
int n, a[333333], sum = 0;

// 未知
int ans = 0;
signed main()
{
    cin >> n;
    for (int i = 1;i <= n;i++)
    {
        cin >> a[i];
        sum += a[i];
    }
    for (int i = 1;i <= n;i++)
    {
        ans += (sum - a[i]) * a[i];
    }
    cout << ans/2;
    return 0;
}